<template>
  <div>
    <div>  
      <table border="1">
        <tr>
          <th width="100px">编号</th>
          <th width="100px">请假人</th>
          <th width="100px">天数</th>
          <th width="100px">类型</th>
          <th width="100px">下一审批人</th>
        </tr>

        <tr v-for="(item, i) in holidaylist" :key="(i)">
          <td>{{ item.id }}</td>
          <td>{{ item.name }}</td>
          <td>{{ item.days }}</td>
          <td>{{ item.type }}</td>

          <td>
            <el-button type="text" @click="sh(item.id)">{{ item.nextid }}</el-button>
          </td>
        </tr>
      </table>
    </div>

    <div>
      <el-dialog title="审核" :visible.sync="dialogVisible" width="30%">
            
            <el-button @click="shenpi">通过</el-button>
            <el-button @click="shenpi2">不通过</el-button>
      </el-dialog>
    </div>
    {{hid}}
  </div>
</template>

<script>
export default {
    name: 'ShenHe',
    data() {
        return {
            holidaylist: [],
            dialogVisible: false,
            hid:"",
        };
    },
    props: {},

    components: {},

    created() {},

    mounted() {
        this.getholiday();
    },

    methods: {
        sh(id){
            this.dialogVisible = true,
            alert(id)
            this.hid=id
        },

        getholiday(){
            this.axios.get("/leave")
            .then((resp) => {
                console.log("获取请假：", resp)
                this.holidaylist=resp.data.user_blue
            }).catch((err) => {
                console.log(err)
            });
        },

        shenpi(){
            this.axios.post("/put",{
                id:this.hid,
                status:1,
            })
            .then((resp) => {
                console.log("审核成功同意：", resp)
                this.dialogVisible = false
                this.getholiday()
            }).catch((err) => {
                console.log(err)
            });
        },

        shenpi2(){
            this.axios.post("/put",{
                id:this.hid,
                status:2,
            })
            .then((resp) => {
                console.log("审核中不成功不同意：", resp)
                this.dialogVisible = false
                this.getholiday()
            }).catch((err) => {
                console.log(err)
            });
        }

    },

    computed: {},

    watch: {},

    directives: {},

    filters: {}
};
</script>

<style scoped></style>
